package org.grottarossa.ui.core.casemanagement;

import java.util.ResourceBundle;

import org.grottarossa.template.drivers.components.tokens.CaseManagementId;
import org.grottarossa.ui.core.ApplicationSession;
import org.grottarossa.ui.core.BPMResource;
import org.grottarossa.ui.core.StylesConstants;
import org.grottarossa.ui.core.base.IBaseComponent;
import org.grottarossa.ui.core.casemanagement.contents.ContentListPanel;
import org.grottarossa.ui.core.casemanagement.discussions.DiscussionListPanel;
import org.grottarossa.ui.core.casemanagement.history.HistoryListPanel;
import org.grottarossa.ui.core.casemanagement.tasks.TaskListPanel;
import org.grottarossa.ui.core.i18n.DM;

import com.vaadin.terminal.Sizeable;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.VerticalLayout;

/***
 * Contiene le tabelle con i contenuti del case folder suddivise in tab
 * @author 
 *
 */
public class CaseTabSheet extends VerticalLayout
{
	private static final long serialVersionUID = -6036612239712903493L;
	protected TabSheet t;
	public ResourceBundle localizer = DM.instance().getBundle(getClass().getName());

	/**layouts*/
	protected VerticalLayout taskLayout;
	protected VerticalLayout contentLayout;
	protected VerticalLayout forumLayout;
	protected VerticalLayout historyLayout;

	/**panels*/
	protected TaskListPanel taskList;
	protected ContentListPanel contentList;
	protected DiscussionListPanel discussionList;
	protected HistoryListPanel historyList;

	private IBaseComponent m_view = null;

	public CaseTabSheet(ApplicationSession appSession, CaseManagementId caseFolderId, IBaseComponent view)
	{
		this.m_view = view;
		taskList = new TaskListPanel(appSession, caseFolderId, m_view, this);
		taskList.setHeight(100, Sizeable.UNITS_PERCENTAGE);

		contentList = new ContentListPanel(appSession, caseFolderId, this);
		contentList.setHeight(100, Sizeable.UNITS_PERCENTAGE);

		discussionList = new DiscussionListPanel(appSession, caseFolderId);
		discussionList.setHeight(100, Sizeable.UNITS_PERCENTAGE);

		historyList = new HistoryListPanel(appSession, caseFolderId);
		historyList.setHeight(100, Sizeable.UNITS_PERCENTAGE);

		t = new TabSheet();

		t.addTab(taskList, localizer.getString("caseFolder.case.tasks.tab"), BPMResource.ICON_CASE_TASK);
		t.addTab(contentList, localizer.getString("caseFolder.case.contents.tab"), BPMResource.ICON_CASE_CONTENT);
		t.addTab(discussionList, localizer.getString("caseFolder.case.discussion.tab"), BPMResource.ICON_CASE_DISCUSSION);
		t.addTab(historyList, localizer.getString("caseFolder.case.history.tab"), BPMResource.ICON_CASE_HISTORY);

		t.setHeight(100, Sizeable.UNITS_PERCENTAGE);
		addComponent(t);
		addStyleName(StylesConstants.TABSHEET_NOBORDER);
	}

	public void refresh()
	{
		taskList.refresh();
		contentList.refresh();
	}
}